package com.axjy.mapper;

import com.axjy.dto.InspectiontaskMainDto;
import com.axjy.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by 00 on 2018/2/24.
 */
public interface InspectiontaskMainMapper {

    public List<InspectiontaskMain> xjzdfp(@Param("offset") Integer offset, @Param("limit") Integer limit, @Param("dto") InspectiontaskMainDto dto);


    public Integer getCount(@Param("dto") InspectiontaskMainDto dto);

    public void add(InspectiontaskMain inspectiontaskMain);


    /**
     * 当主表新增子表也新增
     */
    @Insert("INSERT INTO inspectiontask_detail(task_Id,task_Status,pole_Id,line_Code,line_Name) VALUES(#{taskId},#{taskStatus},#{poleId},#{lineCode},#{lineName})")
    public void zbadd(InspectiontaskDetail detail);


    /**
     * 给子表新增
     * @return
     */
    @Select("SELECT * FROM inspectiontask_main where id=#{id}")
    public InspectiontaskMain zbshow(Integer id);


    @Update("UPDATE inspectiontask_main SET inspection_Task_Code=#{inspectionTaskCode},inspection_Task_Name=#{inspectionTaskName},line_Id=#{lineId},line_Code=#{lineCode},line_Name=#{lineName},start_Pole=#{startPole},start_PoleCode=#{startPolecode},end_Pole=#{endPole},end_PoleCode=#{endPolecode},user_Id=#{userId},user_Name=#{userName},issued_By_Code=#{issuedByCode},issued_By_Name=#{issuedByName},issued_Time=#{issuedTime},common=#{common} where id=#{id}")
    public void update(InspectiontaskMain inspectiontaskMain);

//    public void delete(Map<String, Object> id);

    @Update("UPDATE inspectiontask_main SET is_Cancel=#{isCancel} WHERE id=#{id}")
    public void delete(@Param("isCancel")Integer isCancel,@Param("id") Integer id);

    @Update("UPDATE inspectiontask_main SET user_Id=#{userId},user_Name=#{userName},task_Status=#{taskStatus},task_Status_Name=#{taskStatusName} where id=#{id}")
    public void fpUpdate(InspectiontaskMain inspectiontaskMain);

    @Update("UPDATE USER SET xjzt=1 WHERE id=#{id}")
    public void rwUpdate(Integer id);

    @Update("UPDATE inspectiontask_main SET user_Id=#{userId},user_Name=#{userName} WHERE id=#{id};")
    public void fzrupdate(InspectiontaskMain inspectiontaskMain);



    /**
     * 查询下拉
     * @return
     */
    @Select("SELECT * FROM systemconfig WHERE config_Name='巡检任务状态'")
    public List<Systemconfig> search1();

    @Select("SELECT * FROM line_info")
    public List<LineInfo> search2();

    @Select("SELECT * FROM USER WHERE xjzt=0 AND role_Id=3")
    public List<User> search3();


}
